package pkg

import (
	"fmt"
	"github.com/smartwalle/alipay/v3"
)

type Pay interface {
}
type Ali struct {
	privateKey string
	appId      string
}

func AliPays() *Ali {
	a := &Ali{
		privateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC4PK47nQChur/COYvl0Vl2kRCfo5iIkHiIo8GaL3R48oVKiZuhgpjAAD8jWBIUkF6vkhOpuuSHdTbn7V1I47pepqaOlNTvpLztTRmqJYyutam0uZKcx7rix+i9hDp1mtBWoXP7BVsYWzPxcCH29eyoK5tEG5oVbkS8A63ZTmpoi4vMm6yGi8Sh/CB9Q6K/zmLJeDsvZWIGKOdiOxXbn/sUIMw1Z39VkXd88X51d2QfydsQ7nR4cw7eyfahZnlJu8ux8Fbph1p5IbZoxj+zaBya1KsRUiuNyO6O3BdDWQzlsM98Dj2wvgJq+dmZZmTAgtddlS6M3Nr9aMSLmXZbLLdRAgMBAAECggEAEgfuTWtKOonaZpnXNUDN7qq348fRD9yDz2uncP2f+o5RuT/KeX4ckP31L/JYoqaWfbxgLEZcQ12XaA91B8Mx5D2PI3kxddq7msXm8x4FrLuexk87KBjsE3HZN2MPjZ7/MNtQTIrzpWiXptOAn3jmFndeFMZWyC4oj/YUN6ZTB7QmEUsHuJS3aR/+bViHyGK043mZYpy0i4a/VnYiEcSaiUiRKKw6l28bdD6OaZYbIbXENiIVFSlDtPs9MdGFlxOaMfmgvRtB8aGUJOY+dZ7ui71Ieaj0NZ4Tgzv6Vs0yfXjJi5RDh2Jw8vfXOuI3UOSUFeOfAbM9jXTTr62pYh0w2QKBgQDbrfp23J94KrVP5vILmhsRBHcI8Rgra9bZPnJAAkQRjGcSloKQN9nxIEjgZ3h9IEGWhvhxtDeRLTYFCcSMaR857btKPgoqSo+3stnsmUd3op/Lg/tm2gjLioNv8Q3EAzIEZuq5uZmBof0I3cmxRXuOtv3SAh3Ptce1vd1y9VjAewKBgQDWspUJIwAs8PRLEM/9IKblR5RcJKyO9dQi2JwxF+pO/iRvGBf4ydUayICZQmuYiYO4h3mDtvevQWKvNxhUd4OIhgfCkAd70ibMZsz6lMN7Rh94swoPtxeAHvLQPaNH0gAR34DyYMC1QQNu1okOW4Brb5pwXaKTg5AW2IlxAcirowKBgQC4h9VLwRmnrGBvhPSvMD0qN1DyTutZlhV8mUsJX53kC8eNQqbcFD5boR32epQor07I7gmGIbdHmO22n7TdqXQUihD4VVLeoZFF4tPSPhNdeFq4bt5gUChxKaItBxTkITcDoZvsdO5wiSzvJLbG1THr+OUPYr29+9mNXbbGWTe7PwKBgC/0J1GpHarsDsSNdsdE+cIQYNTL5DbyNXWrCAf3HYCTRzQBH6mT+yNGUWLp8PpbDK60o7GFtoDQi+gy2B5Vq21c8nLElMdVQxE4jOQTQi5QlUryQncMIBWf1AArJEMwZo+Xake40JIreUbSaD5qtZ5JiSc74sosAoz3xIsXKOkdAoGAXiVJSQ8OX85jPvimdEvaJRW9yM4IOE/WlWx5t3A4zphRl70fGdRHMGhXgcr1CziX+mG0hpqIP23PqucisjE0X+jmir1TQwMYQS28iy+tbsE0I3dvgAlFsc7BUCuX9s6Z9ShrzvokzlnVpmgDYJ0Zkh7vG/1IE7zgG3SBKjsLVsk=",
		appId:      "2021000149637324",
	}
	return a
}
func (a Ali) Alipay(OutTradeNo, TotalAmount string) string {
	var client, err = alipay.New(a.appId, a.privateKey, false)
	if err != nil {
		fmt.Println(err)
	}

	var p = alipay.TradeWapPay{}
	p.NotifyURL = "http://xxx"
	p.ReturnURL = "http://baiduwww.com"
	p.Subject = "标题"
	p.OutTradeNo = OutTradeNo
	p.TotalAmount = TotalAmount
	p.ProductCode = "QUICK_WAP_WAY"

	url, err := client.TradeWapPay(p)
	if err != nil {
		fmt.Println(err)
	}

	// 这个 payURL 即是用于打开支付宝支付页面的 URL，可将输出的内容复制，到浏览器中访问该 URL 即可打开支付页面。
	var payURL = url.String()
	fmt.Println(payURL)
	return payURL
}
